package com.logic.landseaserver.ws;

import com.logic.common.enums.HttpCodeEnum;
import com.logic.common.exception.BusinessException;
import com.logic.common.util.CommonResult;
import com.logic.common.util.CommonResultMap;
import com.logic.common.util.QueryUtil;
import com.logic.common.util.SysUtil;
import com.logic.landseaserver.common.LandseaErrorMessageEnum;
import com.logic.landseaserver.common.exception.LandseaBusinessException;
import com.logic.landseaserver.common.util.DateUtil;
import com.logic.landseaserver.service.IProjectAppartment;
import com.logic.landseaserver.service.ISendSmsService;
import com.logic.landseaserver.service.IStatistic;
import com.logic.landseaserver.ws.request.GetSendSmsReq;
import com.logic.landseaserver.ws.request.RoomStatusStatisticReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Date;
import java.util.List;

/**
 * 短信发送
 *
 * @author Daniel
 * @version 2017年4月18日
 */
@Path("/statistic")
@Api(value = "统计")
public class StatisticRest {
    @Autowired
    private IStatistic statisticService;

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @POST
    @Path("/incomeStatistic")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @ApiOperation(value = "运营数据统计")
    public Response queryProjectAppartments(
            @ApiParam(value = "param", required = true) RoomStatusStatisticReq req) {
        CommonResultMap map = new CommonResultMap();
        try {
            map.setData(statisticService.operateStatistic(req));
            map.setResult(CommonResult.SUCCESS);
        } catch (Exception e) {
            logger.error("queryProjectAppartments error.", e);
            map.setResult(CommonResult.ERROR, e.getMessage());
        }
        return Response.status(HttpCodeEnum.OK.getCode()).entity(map).build();
    }

}
